/**
 * 行为树节点基类
 * 
 * 功能：
 * 1. 定义行为树节点的基本结构
 * 2. 提供节点执行接口
 * 3. 管理节点状态
 * 4. 处理节点组合
 * 
 * 特点：
 * 1. 支持复合节点
 * 2. 状态返回机制
 * 3. 条件分支控制
 * 4. 可扩展的节点类型
 */
export enum BehaviorStatus {
    SUCCESS,
    FAILURE,
    RUNNING
}

export abstract class BehaviorNode {
    protected children: BehaviorNode[] = [];

    public abstract tick(): BehaviorStatus;

    public addChild(child: BehaviorNode): void {
        this.children.push(child);
    }
}

export class Sequence extends BehaviorNode {
    public tick(): BehaviorStatus {
        for (const child of this.children) {
            const status = child.tick();
            if (status !== BehaviorStatus.SUCCESS) {
                return status;
            }
        }
        return BehaviorStatus.SUCCESS;
    }
}

export class Selector extends BehaviorNode {
    public tick(): BehaviorStatus {
        for (const child of this.children) {
            const status = child.tick();
            if (status !== BehaviorStatus.FAILURE) {
                return status;
            }
        }
        return BehaviorStatus.FAILURE;
    }
} 